package com.jlf.core.ngac.context;

import com.jlf.core.ngac.domain.Session;

/**
 * 下一代权限的上下文
 *
 * @author wujr
 * 2023/7/5
 * @version 1.0
 * 【变更历史】
 * [wujr 2023/7/5 1.0 新增]
 */
public class NgacContext {
    private static final Session _default = new Session();
    private static final ThreadLocal<Session> _sessions = new ThreadLocal<>();

    public static void session(Session session) {
        _sessions.set(session);
    }

    static {
        _default.setBusiness("unknown");
        _default.setAppCode("unknown");
    }
    public static Session session(){
        Session session = _sessions.get();
        if(session == null){
            session = _default;
        }
        return session;
    }
    public static void clear(){
        _sessions.remove();
    }
}
